<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use App\Common\Constants\PermissionTypeConstants;
use App\Common\Model\CommonRole;
use Hyperf\Database\Model\Relations\BelongsToMany;

class ChSubUser extends ChUser
{
    public function roles(): BelongsToMany
    {
        return $this->belongsToMany(CommonRole::class, 'common_user_role', 'user_id', 'role_id')
            ->withPivot(['permission_type','employee_id'])
            ->wherePivot('permission_type','=',PermissionTypeConstants::CUST_HUB);
    }
}